package com.yanmaohu.nikita.data.structure;

import com.yanmaohu.nikita.data.expression.NameExpression;

/**
 * @author Bright Lee
 */
public final class StructureMember implements Member {

    private final MemberModifier memberModifier;
    private final NameExpression structureName;
    private final StructureBody structureBody;

    public StructureMember(MemberModifier memberModifier, NameExpression structureName, StructureBody structureBody) {
        this.memberModifier = memberModifier;
        this.structureName = structureName;
        this.structureBody = structureBody;
    }

    @Override
    public int getBeginIndex() {
        if (memberModifier != null) {
            return memberModifier.beginIndex();
        }
        return structureName.getBeginIndex();
    }

    @Override
    public int getEndIndex() {
        return structureBody.getEndIndex();
    }

    public MemberModifier getMemberModifier() {
        return memberModifier;
    }

    public NameExpression getStructureName() {
        return structureName;
    }

    public StructureBody getMemberList() {
        return structureBody;
    }

}
